[Bugfix #563] Fix shell buttons broken by stale scrollState in safeFit()#564
Merged
waleedkadous merged 1 commit intomainfrom Feb 26, 2026
Merged
Conversation
PR #561 changed safeFit()'s early-return condition from `if (!baseY)` to `if (!baseY && !scrollState.baseY)`, adding a dependency on the externally- tracked scrollState.baseY. This was unnecessary because baseY (from term.buffer.active.baseY) reflects actual buffer scrollback and is NOT affected by display:none toggling — unlike viewportY which the external tracking was designed to protect. The stale scrollState.baseY could cause safeFit() to take the scroll- preserving path when the buffer had no scrollback (e.g., after a clear), leading to incorrect scroll restoration with stale position values. Fix: Revert to `if (!baseY)` while keeping scrollState.wasAtBottom and scrollState.viewportY for position values (the core Issue #560 fix). Adds regression test for the stale scrollState.baseY scenario. Fixes #563
Contributor
Author
Architect ReviewOne-liner: stale Good regression test. Approved. Architect review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
safeFit()condition fromif (!baseY && !scrollState.baseY)back toif (!baseY)—baseYfromterm.buffer.activeis not affected bydisplay:nonetoggling, soscrollState.baseYis unnecessary and can become stalescrollState.wasAtBottomandscrollState.viewportYusage (the core Issue Terminal still scrolls to top of buffer (regression from #423) #560 fix for viewport position preservation)scrollState.baseYscenarioRoot Cause
PR #561 added
!scrollState.baseYto thesafeFit()early-return condition. WhenscrollState.baseYretained a stale positive value (e.g., after buffer clear or terminal reset),safeFit()would take the scroll-preserving path even when the buffer had no scrollback (baseY=0). This caused incorrect scroll restoration with stale position values, interfering with terminal rendering and button interaction.Test Plan
npx vite build)scrollState.baseYscenarioFixes #563